package IC.AST;

import java.util.List;

import IC.Symbols.Symbol;
import IC.Symbols.SymbolTable;
import IC.Types.ClassType;

/**
 * Class declaration AST node.
 * 
 * @author Tovi Almozlino
 */
public class ICClass extends ASTNode {

	private String name;
	private String parentClass = null;
	private List<Field> fieldList;
	private List<Method> methodList;
    private SymbolTable symbolTable;
    private ClassType semanticType;
    private ClassType parentSemanticType;
    private Symbol symbol;
	public Object accept(Visitor visitor) {
		return visitor.visit(this);
	}

	/**
	 * Constructs a new class node.
	 * 
	 * @param line
	 *            Line number of class declaration.
	 * @param name
	 *            Class identifier name.
	 * @param fields
	 *            List of all fields in the class.
	 * @param methods
	 *            List of all methods in the class.
	 */
	public ICClass(int line, String name, List<Field> fields,
			List<Method> methods) {
		super(line);
		this.name = name;
		methodList = methods;
		fieldList = fields;
	}

	/**
	 * Constructs a new class node, with a superclass.
	 * 
	 * @param line
	 *            Line number of class declaration.
	 * @param name
	 *            Class identifier name.
	 * @param superClassName
	 *            Superclass identifier name.
	 * @param fields
	 *            List of all fields in the class.
	 * @param methods
	 *            List of all methods in the class.
	 */
	public ICClass(int line, String name, String superClassName,
			List<Field> fields, List<Method> methods) {
		this(line, name, fields, methods);
		parentClass = superClassName;
	}

	public String getParentClassName() {
		return parentClass;
	}

	public SymbolTable getClassSymbolTable() {
		return symbolTable;
	}
	
	public String getName() {
		return name;
	}

	public boolean parentClassExists() {
		return (parentClass != null);
	}

	public void setClassSymbolTable(SymbolTable classSymbolTable) {
		symbolTable = classSymbolTable;
	}

	public ClassType getSemanticType() {
		return semanticType;
	}

	public void setSemanticType(ClassType classType) {
		semanticType = classType;
	}

	public ClassType getParentSemanticType() {
		return parentSemanticType;
	}
	
	public List<Field> getFields() {
		return fieldList;
	}

	public List<Method> getMethods() {
		return methodList;
	}

	public void setParentSemanticType(ClassType parentClassType) {
		parentSemanticType = parentClassType;
	}

	public Symbol getSymbolTableEntry() {
		return symbol;
	}

	public void setSymbol(Symbol symbolFromSymbolTable) {
		symbol = symbolFromSymbolTable;
	}

}
